package com.lpy;

import com.springmybatis.LpyImportBeanDefinition;
import com.springmybatis.LpyScan;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;

import java.io.InputStream;

/**
 * @Description:
 * @author: LiuPengYu
 * @date 2024/11/21 16:14
 */
@ComponentScan("com.lpy")
@LpyScan("com.lpy.mapper")
public class AppConfig {

    @Bean
    public SqlSessionFactory sessionFactory()throws Exception{
        InputStream is = Resources.getResourceAsStream("mybatis.xml");
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(is);
        return sqlSessionFactory;
    }
}
